package com.hqyj.serviceLinseter;

import com.hqyj.pojo.UserInfo;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Description
 * @Autor 伍军
 * @Date 2022/10/11 11:02
 * @Version 1.0
 **/
@Component
public class HelloService {

    /**
     * 监听simpleQueve队列的消息
     * @param c 频道 做消息的手动确诊和回退
     * @param m 消息内容
     * @param map
     */
   //@RabbitListener(queues = "simpleQueue")
    public void linsertsimpleQueue(Channel c, Message m , Map<String,Object> map){
       System.out.println("消息内容"+m.getBody());
       System.out.println("消息索引"+m.getMessageProperties().getDeliveryTag());
       System.out.println("用户名"+map.get("name"));
       System.out.println("用户名"+map.get("pwd"));
   }
    //@RabbitListener(queues = "simpleQueue")
    public void linsertsimpleQueue01(Channel c, Message m , UserInfo userInfo){
        System.out.println("我是linsertsimpleQueue01消费");
        System.out.println("消息索引"+m.getMessageProperties().getDeliveryTag());
        System.out.println("用户名"+userInfo.toString());
        ;
    }
    @RabbitListener(queues = "simpleQueue")
    public String linsertsimpleQueue02(Channel c, Message m , UserInfo userInfo){
        System.out.println("我是linsertsimpleQueue02消费");
        System.out.println("消息索引"+m.getMessageProperties().getDeliveryTag());
        System.out.println("用户名"+userInfo.toString());

        return "成功";

    }
}
